﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;

namespace GlTool.GlHttp
{
    /// <summary>
    /// http get请求
    /// </summary>
    public class GlHttpGet : GlHttpBase
    {
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="url">需要访问的url</param>
        public GlHttpGet(String url)
        {
            this.Url = url;
        }

        /// <summary>
        /// 执行
        /// </summary>
        /// <returns></returns>
        public override GlHttpResponse Execute()
        {
            GlHttpResponse response = new GlHttpResponse();
            HttpWebRequest request = this.getRequest();
            request.Method = "GET";
            try
            {
                response.Response = (HttpWebResponse)request.GetResponse();
            }
            catch
            {
                response = null;
            }
            return response;
        }
    }
}
